package com.company.woye.checkmakesure.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.company.woye.R;
import com.company.woye.checkmakesure.bean.LuBuDetailBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MakeSureDeLvBottomAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context mContext;
    private List<LuBuDetailBean.DataBean.DbhListBean> dbhListBeans;

    public MakeSureDeLvBottomAdapter(Context context, List<LuBuDetailBean.DataBean.DbhListBean> dbhListBeans) {
        this.inflater = LayoutInflater.from(context);
        this.mContext = context;
        this.dbhListBeans = dbhListBeans;
    }

    @Override
    public int getCount() {
        return dbhListBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return dbhListBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHodler = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_check_bottom_detail, parent, false);
            viewHodler = new ViewHolder(convertView);
            convertView.setTag(viewHodler);
        } else {
            viewHodler = (ViewHolder) convertView.getTag();
        }
        if (dbhListBeans.size() > 0) {
            LuBuDetailBean.DataBean.DbhListBean dbhListBean = dbhListBeans.get(position);
            viewHodler.tvBdjs.setText(dbhListBean.getBdjs() + "");
            viewHodler.tvDBH.setText(dbhListBean.getDbh() + "");
            viewHodler.tvGy.setText("工艺信息：" + dbhListBean.getGy() + "");
            viewHodler.tvJhrq.setText(dbhListBean.getJhrq().substring(0, 10) + "");
            viewHodler.tvKds.setText(dbhListBean.getKds() + "");
            viewHodler.tvPO.setText(dbhListBean.getPoh() + "");
            viewHodler.tvSize.setText(dbhListBean.getCm() + "");
            viewHodler.tvZps.setText(dbhListBean.getZps() + "");
            viewHodler.tvSz.setText(dbhListBean.getPsxx() + "");

//            if (dbhListBeans.size() % 2 == 0){
//                viewHodler.lltop.setBackgroundColor(Color.WHITE);
//            }else {
//                viewHodler.lltop.setBackgroundColor(mContext.getResources().getColor(R.color.lightGreen_));
//            }
        }
        return convertView;
    }



    class ViewHolder {
        @BindView(R.id.tv_DBH)
        TextView tvDBH;
        @BindView(R.id.tv_PO)
        TextView tvPO;
        @BindView(R.id.tv_size)
        TextView tvSize;
        @BindView(R.id.tv_kds)
        TextView tvKds;
        @BindView(R.id.tv_bdjs)
        TextView tvBdjs;
        @BindView(R.id.tv_zps)
        TextView tvZps;
        @BindView(R.id.tv_jhrq)
        TextView tvJhrq;
        @BindView(R.id.tv_sz)
        TextView tvSz;
        @BindView(R.id.ll)
        LinearLayout ll;
        @BindView(R.id.tv_gy)
        TextView tvGy;
        @BindView(R.id.lltop)
        LinearLayout lltop;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
